home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cenvid / autoexec.cmm < prev    next >
Text File  |  1995-10-20  |  1KB  |  45 lines

  1. // AutoExec.cmm - Loaded for CEnvi shell, which is if CEnvi
  2. // ver.1          is executed with no arguments.
  3. //
  4. //                This version runs INSTALL.CMM and then
  5. //                replaces instal with an AUTOEXEC.CMM that
  6. //                does nothing.
  7.  
  8. main(argc,argv)
  9. {
  10.    if defined(_NTCON_)
  11.    {
  12.       printf("NT Install must be run from CENVIWNT.EXE. Please run it first\n");
  13.       exit(0);
  14.    }
  15.    // get full name of AUTOEXEC.CMM
  16.    FullName = FullPath(argv[0]);
  17.  
  18.    // Run the INSTALL.CMM script in same directory
  19.    sprintf(InstallScript,"%sINSTALL.CMM",SplitFileName(FullName).dir);
  20.    if ( !Directory(InstallScript) ) {
  21.       printf("\aCannot find \"%s\"!\n",InstallScript);
  22.       exit(EXIT_FAILURE);
  23.    }
  24.    interpret(InstallScript);
  25.  
  26.    // replace AUTOEXEC.CMM with one that does nothing, or delete it
  27.    if ( !(fp = fopen(FullName,"wt")) ) {
  28.       // couldn't open.  Maybe must fix attribute
  29.       system("attrib -r -h -s %s",FullName);
  30.       suspend(3000);
  31.       fp = fopen(FullName,"wt");
  32.       if ( !(fp = fopen(FullName,"wt")) ) {
  33.          // try to delete, but that's all we can do
  34.          remove(FullName);
  35.          exit(EXIT_FAILURE);
  36.       }
  37.    }
  38.    fprintf(fp,"// AutoExec.cmm - Loaded for CEnvi shell, which is if CEnvi\n");
  39.    fprintf(fp,"// ver.1          is executed with no arguments.\n");
  40.    fclose(fp);
  41.  
  42.    // really exit CEnvi including the shell
  43.    abort(TRUE);
  44. }
  45.